package com.iflytek.universitymanagement.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.iflytek.universitymanagement.domain.StudentGrowth;

import com.iflytek.universitymanagement.domain.StudyHabit;
import com.iflytek.universitymanagement.mapper.StudentGrowthMapper;
import com.iflytek.universitymanagement.service.StudentGrowthService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StudentGrowthServiceImpl extends ServiceImpl<StudentGrowthMapper, StudentGrowth> implements StudentGrowthService {


@Autowired
private StudentGrowthMapper studentGrowthMapper;


//    @Override
//    public StudentGrowth getGrowthByStudentId(Integer studentId) {
//        return this.lambdaQuery().eq(StudentGrowth::getStudentId, studentId).one();
//    }



//    @Override
//    public List<StudentGrowth>  getGrowthByStudentId(Integer studentId) {
//        return studentGrowthMapper.getStudentGrowthsWithNames(studentId);
//    }

    @Override
    public StudentGrowth getGrowthByStudentId(Integer studentId) {
        // 获取学生成长数据列表
        List<StudentGrowth> growthList = studentGrowthMapper.getStudentGrowthsWithNames(studentId);

        // 如果列表不为空，则返回第一个元素；如果为空，返回 null 或处理为默认值
        if (growthList != null && !growthList.isEmpty()) {
            return growthList.get(0); // 返回第一个成长数据
        }
        return null; // 或者抛出异常，具体根据业务需求
    }

//    @Override
//    public List<StudentGrowth> getAllStudentGrowths() {
//        return studentGrowthMapper.getAllStudentGrowthsWithNames();
//    }
@Override
public Page<StudentGrowth> getAllStudentGrowthsWithNames(Page<StudentGrowth> page) {
    return studentGrowthMapper.getAllStudentGrowthsWithNames(page);
}

//    @Override
//    public List<StudentGrowth> getAllStudentGrowths() {
//        return studentGrowthMapper.getAllStudentGrowthsWithNames();
//    }
}
